package com.base.social.domain;


import com.base.social.enums.AuthUserGender;

import java.io.Serializable;

/**
 * 授权成功后的用户信息，根据授权平台的不同，获取的数据完整性也不同
 *
 * @author becker
 * @since 0.0.1
 */
public class AuthUser implements Serializable {
    /**
     * 用户第三方系统的唯一openid。在调用方集成改组件时，可以用openid + source唯一确定一个用户
     *
     */
    private String openid;

    /**
     * 用户第三方系统全局唯一id，仅仅用于微信
     */
    private String unionid;
    /**
     * 用户名
     */
    private String username;
    /**
     * 用户昵称
     */
    private String nickname;
    /**
     * 用户头像
     */
    private String avatar;
    /**
     * 用户网址
     */
    private String userUrl;
    /**
     * 所在公司
     */
    private String company;
    /**
     * 位置
     */
    private String location;
    /**
     * 用户邮箱
     */
    private String email;
    /**
     * 用户备注（各平台中的用户个人介绍）
     */
    private String remark;

    /**
     * 性别
     */
    private AuthUserGender gender;

    /**
     * 用户来源
     */
    private String source;

    /**
     * 用户授权的token信息
     */
    private AuthToken token;

    public AuthUser(String openid, String unionid, String username, String nickname, String avatar, String userUrl,
                    String company, String location, String email, String remark, AuthUserGender gender, String source,
                    AuthToken token) {
        this.openid = openid;
        this.unionid = unionid;
        this.username = username;
        this.nickname = nickname;
        this.avatar = avatar;
        this.userUrl = userUrl;
        this.company = company;
        this.location = location;
        this.email = email;
        this.remark = remark;
        this.gender = gender;
        this.source = source;
        this.token = token;
    }

    public AuthUser() {
    }

    public static AuthUserBuilder builder() {
        return new AuthUserBuilder();
    }

    public String getOpenid() {
        return this.openid;
    }

    public String getUnionid() {
        return this.unionid;
    }

    public String getUsername() {
        return this.username;
    }

    public String getNickname() {
        return this.nickname;
    }

    public String getAvatar() {
        return this.avatar;
    }

    public String getUserUrl() {
        return this.userUrl;
    }

    public String getCompany() {
        return this.company;
    }

    public String getLocation() {
        return this.location;
    }

    public String getEmail() {
        return this.email;
    }

    public String getRemark() {
        return this.remark;
    }

    public AuthUserGender getGender() {
        return this.gender;
    }

    public String getSource() {
        return this.source;
    }

    public AuthToken getToken() {
        return this.token;
    }

    public void setOpenid(String openid) {
        this.openid = openid;
    }

    public void setUnionid(String unionid) {
        this.unionid = unionid;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public void setBlog(String userUrl) {
        this.userUrl = userUrl;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    public void setLocation(String location) {
        this.location = location;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public void setGender(AuthUserGender gender) {
        this.gender = gender;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public void setToken(AuthToken token) {
        this.token = token;
    }

    public static class AuthUserBuilder {
        private String openid;
        private String unionid;
        private String username;
        private String nickname;
        private String avatar;
        private String userUrl;
        private String company;
        private String location;
        private String email;
        private String remark;
        private AuthUserGender gender;
        private String source;
        private AuthToken token;

        AuthUserBuilder() {
        }

        public AuthUser.AuthUserBuilder openid(String openid) {
            this.openid = openid;
            return this;
        }

        public AuthUser.AuthUserBuilder unionid(String unionid) {
            this.unionid = unionid;
            return this;
        }

        public AuthUser.AuthUserBuilder username(String username) {
            this.username = username;
            return this;
        }

        public AuthUser.AuthUserBuilder nickname(String nickname) {
            this.nickname = nickname;
            return this;
        }

        public AuthUser.AuthUserBuilder avatar(String avatar) {
            this.avatar = avatar;
            return this;
        }

        public AuthUser.AuthUserBuilder userUrl(String userUrl) {
            this.userUrl = userUrl;
            return this;
        }

        public AuthUser.AuthUserBuilder company(String company) {
            this.company = company;
            return this;
        }

        public AuthUser.AuthUserBuilder location(String location) {
            this.location = location;
            return this;
        }

        public AuthUser.AuthUserBuilder email(String email) {
            this.email = email;
            return this;
        }

        public AuthUser.AuthUserBuilder remark(String remark) {
            this.remark = remark;
            return this;
        }

        public AuthUser.AuthUserBuilder gender(AuthUserGender gender) {
            this.gender = gender;
            return this;
        }

        public AuthUser.AuthUserBuilder source(String source) {
            this.source = source;
            return this;
        }

        public AuthUser.AuthUserBuilder token(AuthToken token) {
            this.token = token;
            return this;
        }

        public AuthUser build() {
            return new AuthUser(openid, unionid, username, nickname, avatar, userUrl, company, location, email, remark,
                    gender, source, token);
        }

        public String toString() {
            return "AuthUser.AuthUserBuilder(openid=" + this.openid + ", unionid=" + this.unionid + ", username=" +
                    this.username + ", nickname=" + this.nickname + ", avatar=" + this.avatar + ", userUrl=" +
                    this.userUrl + ", company=" + this.company + ", location=" + this.location + ", email=" +
                    this.email + ", remark=" + this.remark + ", gender=" + this.gender + ", source=" + this.source
                    + ", token=" + this.token + ")";
        }
    }
}
